#include <iostream>
using namespace std;

struct node
{ int info;
  node * next;
};
  
struct Queue
{ int n;
  node *first, *last;
  Queue()
  { n=0; first=last=NULL; }
};  

void push(Queue &q, int x)
{ node *p = new node;
  p->info = x;
  p->next = NULL;
  if(q.n==0)
  { q.first=q.last=p; }
  else
  { q.last->next = p;
    q.last = p;
  }  
  q.n++;  
}

int front(Queue q)
{ return q.first->info; }

void pop(Queue &q)
{ if(q.n>0)
  { node *p = q.first;
    q.first = p->next;
    delete p;
    q.n--;
  }  
}

void clear(Queue &q)
{ while(q.n > 0) 
    pop(q);
}


int size(Queue q)
{ return q.n; }

bool empty(Queue q)
{ return q.n==0; }
   
  
int main()
{ Queue q;

  push(q,10); push(q,15); push(q,12);
  cout << front(q) << endl;
  cout << size(q) << endl;
  pop(q);
  cout << front(q) << endl;
  cout << size(q) << endl;
  push(q,30);
  
  while(!empty(q))
  { cout << front(q) << " ";
    pop(q);
  }  
  cout << endl;
 
  return 0;
}    
